package com.fowo.api.controller.purchase;


import com.fowo.api.common.model.ImportRow;
import com.fowo.api.common.model.R;
import com.fowo.api.controller.purchase.importPo.StockInProductImportPo;
import com.fowo.api.model.stock.in.product.StockInProductItemVo;
import com.fowo.api.model.stock.in.product.StockInProductVo;
import com.fowo.api.service.handleWork.StockInProductDServiceImpl;
import com.fowo.api.sys.entity.SysFile;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "入库单子表")
@RequestMapping("/api/stock-in-product")
@RestController
public class StockInProductDController {

    @Resource
    private StockInProductDServiceImpl service;

    @Operation(summary = "导入预览")
    @PostMapping("/import-preview")
    public R<List<StockInProductItemVo>> importPreview(@RequestBody SysFile sysFile,
                                                       @RequestParam(name = "template", required = false) Long templateId,
                                                       @RequestParam(name = "wid", required = false) Long wid,
                                                       @RequestParam(
                                                                             name = "allowOverrides",
                                                                             defaultValue = "false"
                                                                     ) boolean allowOverrides) {
        return R.data(() -> service.importPreview(sysFile,templateId,allowOverrides,wid));
    }
}
